package com.tuhao.www.service;

import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;

import com.github.pagehelper.PageInfo;
import com.tuhao.www.util.Page;

public interface BaseService<T, Serializable> {  
    
	/**
     * 添加数据-实体全属性
     * @return
     */
    public int insert(T record);
    
    /**
     * 添加数据
     * @return
     */
    public int insert(String nameSpace, T record);
    
    /**
     * 添加数据-实体可选属性
     * @param record
     * @return
     */ 
    public int insertSelective(T record);
    
    /**
     * 查询某个实体
     * @param id
     * @return
     */
    public T selectByPrimaryKey(Long id);
    
    /**
     * 更新某个实体-全属性  
     * @param record
     * @return
     */
    public int updateByPrimaryKey(T record);
    
    /**
     * 更新某个实体-可选属性
     * @param record
     * @return
     */
    public int updateByPrimaryKeySelective(T record);
    
    /**
     * 更新某个实体-可选属性--传入值为map
     * @param param
     * @return
     */
    public int updateByPrimaryKeySelective(Map<String, Object> param);
    
    /**
     * 删除某个实体
     * @param id
     * @return
     */
    public int deleteByPrimaryKey(Long id);
    
    /**
     * 删除实体
     * @return
     */
    public int delete(String nampSpace, Map<String, Object> param);
    
    /**
     * 实体查询-第一条
     * @param statementKey
     * @param parameter
     * @return
     * @throws IllegalAccessException
     * @throws InvocationTargetException
     * @throws NoSuchMethodException
     */
    public List<T> findTop(int top, String statementKey, Object parameter) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException;
    
    /**
     * 实体查询-前一条
     * @param statementKey
     * @param parameter
     * @return
     * @throws IllegalAccessException
     * @throws InvocationTargetException
     * @throws NoSuchMethodException
     */
    public T findTopOne(String statementKey, Object parameter) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException;
    
    /**
     * 实体查询-分页/不分页
     * @param statementKey
     * @param page
     * @param parameter
     * @return
     * @throws IllegalAccessException
     * @throws InvocationTargetException
     * @throws NoSuchMethodException
     */
    public PageInfo pageFind(String statementKey, Page page, Object parameter, Boolean isSimplePage) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException;
    
    /**
     * 实体查询-分页
     * @param statementKey
     * @param page
     * @param parameter
     * @return
     * @throws IllegalAccessException
     * @throws InvocationTargetException
     * @throws NoSuchMethodException
     */
    public <M> PageInfo pageFindModel(String statementKey, Page page, Object parameter) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException;
    
    /**
     * 实体查询-分页/不分页
     * @param statementKey
     * @param page
     * @param parameter
     * @return
     * @throws IllegalAccessException
     * @throws InvocationTargetException
     * @throws NoSuchMethodException
     */
    public <M> PageInfo pageFindModel(String statementKey, Page page, Object parameter, Boolean isSimplePage) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException;
   
    /**
     * 实体查询-所有
     * @param statementKey
     * @param param
     * @return
     * @throws IllegalAccessException
     * @throws InvocationTargetException
     * @throws NoSuchMethodException
     */
    public List<T> selectList(String statementKey, Map<String, Object> param) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException;
    
}
